<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%String path = request.getContextPath();%>
<%@ include file="../common/tags.jsp" %>
<script type="text/javascript">
function submitUserListForm(form){
	if('${searchType}'=='')
		return navTabSearch(form);
	else
	    return dwzSearch(form, 'dialog');
}
</script>
<form id="pagerForm" method="post" action="<%=path %>/user/listUser.action">
	<input type="hidden" name="pageRequest" value="1" />
	<input type="hidden" name="pageNum" value="${paginator.pageIndex}" />
	<input type="hidden" name="numPerPage" value="${paginator.pageSize}" />
</form>
<div class="pageHeader">
	<div class="searchBar">
		<form onsubmit="return submitUserListForm(this);" rel="pagerForm" action="<%=path %>/user/listUser.action" method="post">
			<input type="hidden" name="searchType" value="${searchType}"/>
			<ul class="searchContent">
				<li>
					<label style="text-align: right;">账号：</label>
					<input type="text" name="userVO.account" value='<s:property value="userVO.account" />' />
				</li>
				<li>
					<label style="text-align: right;">姓名：</label>
					<input type="text" name="userVO.name" value='<s:property value="userVO.name" />' />
				</li>
				<li>
					<label style="text-align: right;">状态：</label>
					<select name="userVO.status" class="combox">
                        <option value="1" ${userVO.status == 1 ?"selected":"" }>有效</option>
                        <option value="-1" ${userVO.status == -1 ?"selected":"" }>失效</option>
                        <option value="0" ${userVO.status == 0 ?"selected":"" }>暂停</option>
                   </select>
				</li>
			</ul>
			<ul class="searchContent">
				<li>
					<label style="text-align: right;">开户日期：</label>
					从<input type="text" name="userVO.gtcreateDate" value="<s:date format="yyyy-MM-dd" name="userVO.gtcreateDate"/>" class="date param" dateFmt="yyyy-MM-dd" readonly="true" size="10"/>
					到<input type="text" name="userVO.ltcreateDate" value="<s:date format="yyyy-MM-dd" name="userVO.ltcreateDate"/>" class="date param" dateFmt="yyyy-MM-dd" readonly="true" size="10"/>
				</li>
				<c:choose>
				<c:when test="${SESSION_USER.customer==null}">
					<input name="userVO.customerId" value="<s:property value="userVO.customerId" />" type="hidden">
					<c:if test="${searchType==null||searchType==''}">
						<li>
							<label style="text-align: right;">所属商家：</label>
							<input onclick="$('#user_list_a_btnLook').trigger('click');" style="cursor: pointer;float: left;" name="userVO.customerName" value="<s:property value="userVO.customerName" />">
							<!-- <a class="btnLook" id="user_list_a_btnLook" href="<%=path %>/customer/listCustomer.action?searchType=active" lookupGroup="userVO">选择</a> -->
						</li>
					</c:if>
				</c:when>
				<c:otherwise>
					<input name="userVO.customerId" value="${SESSION_USER.customer.id}" type="hidden">
				</c:otherwise>
				</c:choose>
			</ul>
			<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
			</ul>
		</div>
		</form>
		<c:if test="${searchType==null || searchType==''}">
			<shiro:hasPermission name="importUsers">
            
			<form method="post" rel="importForm" action="<%=path %>/user/importUsers.action" class="pageForm required-validate" onsubmit="ifarmeCallback(this);" enctype="multipart/form-data">
				<ul class="searchContent">
					<li>  
						<input name="importFile" type="file" size="20"/>
					</li>
                    <li>  
                      <button type="submit">导入</button>
                      <a href="<%=path %>/jsp/common/users-upload-sample.xls">下载导入模版</a>
                    </li>
				</ul>
			</form>
			</shiro:hasPermission>
		</c:if>
	</div>
</div>
<div class="pageContent">
	<c:if test="${searchType==null || searchType==''}">
		<div class="panelBar">
			<ul class="toolBar">
				<shiro:hasPermission name="addUser">
				<li><a class="add" href="<%=path %>/user/addUser.action" target="navTab"><span>添加</span></a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="deleteUser">
				<li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids" postType="string" href="<%=path %>/user/deleteUser.action" class="delete"><span>删除</span></a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="editUser">
				<li><a class="edit" href="<%=path %>/user/editUser.action?userVO.id={sid_user}" target="navTab" warn="请选择一个用户"><span>修改</span></a></li>
				</shiro:hasPermission>
			</ul>
		</div>
	</c:if>
	<table class="table" width="100%" layoutH="189">
		<thead>
			<tr>
				<th width="30"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				<th width="100">账号</th>
				<th >姓名</th>
				<th width="100">角色</th>
				<th width="100">商家</th>
				<th>工号ID</th>
				<th>联系电话</th>
				<th>联系邮件</th>
				<th>工号状态</th>
				<th>开户日期</th>
				<th width="70">操作</th>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="userList" id="user" status="st">
				<tr target="sid_user" rel="<s:property value="id" />">
					<td><input name="ids" value="<s:property value="id" />" type="checkbox"></td>
					<td><s:property value="account" /></td>
					<td><s:property value="name" /></td>
					<td><s:property value="roleName" /></td>
					<td><s:property value="customer.name" /></td>
		             <td><s:property value="employId" /></td>	
		             <td><s:property value="tel" /></td>	
		             <td><s:property value="email" /></td>	
		             <td>
		             	<c:choose>
		             	<c:when test="${1==status}">有效</c:when>  
		             	<c:when test="${0==status}">暂停</c:when>  
   						 <c:otherwise>失效</c:otherwise>
						</c:choose>
		             </td>
		             <td><s:date name="createDate" format="yyyy-MM-dd"/></td>	
					<td>
						<c:if test="${searchType==null || searchType==''}">
							<shiro:hasPermission name="deleteUser">
							<a title="确实要删除这条记录吗?" target="ajaxTodo" href="<%=path %>/user/deleteUser.action?ids=<s:property value="id" />" class="btnDel">删除</a>
							</shiro:hasPermission>
							<shiro:hasPermission name="editUser">
							<a title="编辑" target="navTab" href="<%=path %>/user/editUser.action?userVO.id=<s:property value="id" />" class="btnEdit">编辑</a>
							</shiro:hasPermission>
						</c:if>
						<c:if test="${searchType == 'lookup'}">
							<a class="btnSelect" href="javascript:$.bringBack({operatorId:'${id}', operatorName:'${name}'})" title="查找带回">选择</a>
						</c:if>
					</td>
				</tr>
			</s:iterator>
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
				<span>显示</span>
				<select class="combox" name="numPerPage" onchange='<s:if test="%{searchType==null||searchType==''}">navTabPageBreak({numPerPage:this.value})</s:if><s:else>dialogPageBreak({numPerPage:this.value})</s:else>'>
					<option value="15" <c:if test="${paginator.pageSize==15}">selected='selected'</c:if> >15</option>
					<option value="30" <c:if test="${paginator.pageSize==30}">selected='selected'</c:if> >30</option>
					<option value="50" <c:if test="${paginator.pageSize==50}">selected='selected'</c:if> >50</option>
					<option value="100" <c:if test="${paginator.pageSize==100}">selected='selected'</c:if> >100</option>
					<option value="200" <c:if test="${paginator.pageSize==200}">selected='selected'</c:if> >200</option>
				</select>
				<span>条，共${paginator.totalCount}条</span>
			</div>
			<div class="pagination" targetType="${(searchType==null||searchType=='')?'navTab':'dialog'}" totalCount="${paginator.totalCount}" 
				numPerPage="${paginator.pageSize}" pageNumShown="10" currentPage="${paginator.pageIndex}"></div>
	</div>
</div>
